﻿using System;
using IPCChannel;

namespace UProveAPI
{
    public class UProveTCPClient : TCPClient
    {
        public UProveTCPClient(string ip, int port) 
            : base(ip, port)
        {
        }

        protected override IPCMessage MessageDeserialization(string typeHeader, string jsonMessage)
        {
            IPCMessage msgObj = null;
            Type messageType = Type.GetType(typeHeader);
            if (messageType == typeof(SetupMessage))
                msgObj = IPCMessage.Deserialize<SetupMessage>(jsonMessage);
            else if (messageType == typeof(IssuanceMessage))
                msgObj = IPCMessage.Deserialize<IssuanceMessage>(jsonMessage);
            else if (messageType == typeof(PresentationMessage))
                msgObj = IPCMessage.Deserialize<PresentationMessage>(jsonMessage);

            return msgObj;
        }
    }
}
